(function(app) {
    app
        .controller("content_29_checkCtrl", ["$scope", "myFactory", '$http', '$stateParams', '$state', function($scope, myFactory, $http, $stateParams, $state) {

            //接收参数
            var item29 = $stateParams.item29;
            var mid = $stateParams.mid;
            var itemids = $stateParams.itemids;
            var chdrnum01 = $stateParams.chdrnum;
            var state = $stateParams.state; //跳转路由
            var chdrcoy = $stateParams.chdrcoy;
            $scope.chdrnum01 = chdrnum01;

            //映射到页面
            $scope.item29 = $stateParams.item29;
            $scope.showFlag = true; //控制前端是否显示“详情、重审、退出”三个功能



            $scope.data = {
                    changeCon: []
                },
                //重新受理
                $scope.renew = function() {
                    myFactory.renew();
                }
                //退出移动保全
            $scope.exit = function() {
                myFactory.exit();
            }

            //返回函数
            $scope.goBack = function() {
                //history.go(-1);
                //				$state.go(state,{
                //					"item":item,
                //					"chdrnum01":chdrnum01,
                //					"mid":mid,
                //					"itemids":itemids
                //				});
                myFactory.goBack();
            }

            //保单详情弹窗
            $scope.showPolicyDetail = function() {
                modal('open', 'policyModalOn29Check', 'policyWindowOn29Check', 'policyCloseXOn29Check');
                var token = sessionStorage.getItem("token");
                var timestamp = myFactory.getTimetamp();
                var sfis = "chdrnum-chdrcoy-token-timestamp";
                var signStr = "chdrnum=" + chdrnum01 + "&chdrcoy=" + chdrcoy + "&token=" + token + "&timestamp=" + timestamp; //encodeURI(name)
                var sign = myFactory.hex(signStr);
                //初始化查询订单详情
                var policyData;
                $http({
                    method: 'GET',
                    url: app.domain + 'query/restFindPolicyDetail.action',
                    params: { 'chdrnum': chdrnum01, 'chdrcoy': chdrcoy, 'sign': sign, 'sfis': sfis, 'token': token, 'timestamp': timestamp }
                }).then(function successCallback(response) {
                    if (response.data.success) {
                        policyData = response.data.data;
                        $scope.policyData = policyData;
                    }
                }, function errorCallback(response) {
                    $.alert({
                        title: '',
                        text: '初始化查询订单详情失败!',
                        onOK: function() {
                            //点击确认
                        }
                    });
                });

            }

            //保单详情弹窗关闭函数
            $scope.policyCancelOn29Check = function() {
                modal('close', 'policyModalOn29Check', 'policyWindowOn29Check', 'policyCloseXOn29Check');
            }

            //关闭遮罩
            $scope.overwindowClose = function() {
                //$(".overwindow").show();
                $(".overwindow").hide();
                $(".overmodal").hide();
            }

            //根据路由判断是否要显示详情、重新受理、退出三个功能
            if ("history_detail" == state) {
                $scope.showFlag = false; //不显示
            }

        }]);

    //指针弹窗
    app.directive('infoid', function() {
        return {
            restrict: 'EA', //指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
            templateUrl: 'html/input/content_base_info.html' + app.clearCache,
            replace: true, //设置解析后，DOM声明的指令是否消失
            link: function(scope, element, attrs) { //链接函数负责注册DOM事件和更新DOM,
                console.log('指令完成');
            }
        }
    });

})(app)